package com.loan.web.pdf.controller.create;

import com.loan.common.annotation.Log;
import com.loan.common.core.controller.BaseController;
import com.loan.common.core.domain.AjaxResult;
import com.loan.common.core.page.TableDataInfo;
import com.loan.common.enums.BusinessType;
import com.loan.common.utils.poi.ExcelUtil;
import com.loan.system.create.domain.AssistPdfSearchZfbBase;
import com.loan.system.create.service.IAssistPdfSearchZfbBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * ZFB数据Controller
 *
 * @author Sophia
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/system/zfbSearch")
public class AssistPdfSearchZfbBaseController extends BaseController {
    @Autowired
    private IAssistPdfSearchZfbBaseService assistPdfSearchZfbBaseService;

    /**
     * 查询ZFB数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssistPdfSearchZfbBase assistPdfSearchZfbBase) {
        startPage();
        List<AssistPdfSearchZfbBase> list = assistPdfSearchZfbBaseService.selectAssistPdfSearchZfbBaseList(assistPdfSearchZfbBase);
        return getDataTable(list);
    }

    /**
     * 导出ZFB数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:export')")
    @Log(title = "ZFB数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssistPdfSearchZfbBase assistPdfSearchZfbBase) {
        List<AssistPdfSearchZfbBase> list = assistPdfSearchZfbBaseService.selectAssistPdfSearchZfbBaseList(assistPdfSearchZfbBase);
        ExcelUtil<AssistPdfSearchZfbBase> util = new ExcelUtil<AssistPdfSearchZfbBase>(AssistPdfSearchZfbBase.class);
        util.exportExcel(response, list, "ZFB数据数据");
    }

    /**
     * 获取ZFB数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(assistPdfSearchZfbBaseService.selectAssistPdfSearchZfbBaseById(id));
    }

    /**
     * 新增ZFB数据
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:add')")
    @Log(title = "ZFB数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssistPdfSearchZfbBase assistPdfSearchZfbBase) {
        return toAjax(assistPdfSearchZfbBaseService.insertAssistPdfSearchZfbBase(assistPdfSearchZfbBase));
    }

    /**
     * 修改ZFB数据
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:edit')")
    @Log(title = "ZFB数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssistPdfSearchZfbBase assistPdfSearchZfbBase) {
        return toAjax(assistPdfSearchZfbBaseService.updateAssistPdfSearchZfbBase(assistPdfSearchZfbBase));
    }

    /**
     * 删除ZFB数据
     */
    @PreAuthorize("@ss.hasPermi('system:zfbSearch:remove')")
    @Log(title = "ZFB数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(assistPdfSearchZfbBaseService.deleteAssistPdfSearchZfbBaseByIds(ids));
    }
}
